package cn.momoshenchi.medicine.handler;

import io.goeasy.GoEasy;
import io.goeasy.publish.GoEasyError;
import io.goeasy.publish.PublishListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @version : 1.0
 * @author: momoshenchi
 * @date: 2021/7/20 - 10:41
 */
@Component
public class PubHandler extends PublishListener
{
    @Value("${goeasy.host}")
    private  String host;

    @Value("${goeasy.appKey}")
    private  String appKey;

    @Bean
    public GoEasy goEasy()
    {
        return new GoEasy(host,appKey);
    }

    @Override
    public void onSuccess()
    {
        System.out.println("Publish success.");
    }

    @Override
    public void onFailed(GoEasyError error)
    {
        System.out.println("Failed to Publish message, error:" + error.getCode() + " , " + error.getContent());
    }
}
